//开启插件
var Plug = {
    //载入执行文件
    open: function (name, func) {
        var self = this;
        if (typeof (self[name]) == 'undefined') {
            this.load(name, func);
        } else {
            func && func();
        }
    },
    load: function (name, func) {
        var url = '//i.xuezizhai.com/js/utf8/plus/' + name + '.js';
        var script = document.createElement("script");
        script.type = "text/javascript";
        if (script.readyState) { //IE
            script.onreadystatechange = function () {
                if (script.readyState == "loaded" || script.readyState == "complete") {
                    script.onreadystatechange = null;
                    func && func();
                }
            };
        } else {
            script.onload = function () {
                func && func();
            };
        }
        script.src = url;
        document.body.appendChild(script);
    }
}

/*
	行为日志
*/
Plug.log = {
    url: 'http://xyh.xuezizhai.com/index.php?s=40&module=census',
    /**日志基本信息
     * @access    public
     * @return    object
     */
    getData: function (param, func, data) {
        param = param || {};
        var url = this.url;
        for (var i in param) url += "&" + i + "=" + param[i];
        url += '&api=1';
        irm.get(url, func, 'json', data);
    },
    //行为轨迹
    deed: function (item) {
        item.view = 'deed';
        item.cm = 'add';
        this.getData(item);
    },
    //行为轨迹
    teacherdeed: function (item, func) {
        item.view = 'teacherdeed';
        item.cm = 'add';
        this.getData(item, func);
    }
}

function QueryLoad() {
    if (typeof ($) == 'function') {
        if (typeof (init) == 'function') init();
    } else {
        setTimeout('QueryLoad()', 200);
    }
}

QueryLoad();